import type { EntityDto } from '@/models/entity';
import type { MenuDto, MenuResultDto } from '@/models/menu';
import { httpApi } from '@/utils/axios/http';
import url from '@/utils/axios/url';

export function getMenusApi(code?: string): Promise<Array<MenuResultDto>> {
    return httpApi.httpGet({ url: url.menu, params: { code: code } });
}

export function getMenuApi(id: number): Promise<MenuResultDto> {
    return httpApi.httpGet({ url: url.menu + '/' + id });
}

export function postMenuApi(input: MenuDto): Promise<MenuResultDto> {
    return httpApi.httpPost({ url: url.menu, params: input });
}

export function putMenuApi(input: MenuDto): Promise<MenuResultDto> {
    return httpApi.httpPut({ url: url.menu, params: input });
}

export function deleteMenuApi(id: number): Promise<EntityDto> {
    return httpApi.httpDelete({ url: url.menu+ '/' + id});
}